package com.central.scheduler.plugin.task.datasource;

import com.central.common.enums.DbType;
import com.central.common.model.DatasourceInfo;

import javax.xml.crypto.Data;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author Tindy
 * @date 2021/12/23
 * @describe
 */
public interface DatasourceProcessor {

    /**
     *  datasource connection param
     *
     * @param datasource
     */
    ConnectionParam createConnectionParams(DatasourceInfo datasource);

    /**
     * get datasource Driver
     */
    String getDatasourceDriver();

    /**
     * get jdbcUrl by connection param, the jdbcUrl is different with ConnectionParam.jdbcUrl, this method will inject
     * other to jdbcUrl
     *
     * @param connectionParam connection param
     */
    String getJdbcUrl(ConnectionParam connectionParam);

    /**
     * get connection by connectionParam
     *
     * @param connectionParam connectionParam
     * @return {@link Connection}
     */
    Connection getConnection(ConnectionParam connectionParam) throws ClassNotFoundException, SQLException, IOException;

    /**
     * @return {@link DbType}
     */
    DbType getDbType();
}
